package day1206zy.day1206zy7;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

public class demo7 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        List<String> list = FileUtils.readLines(new File("src\\day1206zy7\\CatData.txt"));
        String str="";
        for (String s : list) {
            str=s.split("'")[1];
        }
        Class<?> clazz = Class.forName("day1206zy7.Cat");
        Method setName = clazz.getDeclaredMethod("setName", String.class);
        Object o = clazz.getDeclaredConstructor().newInstance();
        setName.invoke(o,str);
        Method getName = clazz.getDeclaredMethod("getName");
        Object invoke = getName.invoke(o);
        System.out.println(invoke);
    }
}
